package tech.aistar.controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import tech.aistar.mapper.SingerListMapper;
import tech.aistar.pojo.entity.SingerList;
import tech.aistar.vo.Result;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("singer")
public class SingerController {

    @Autowired
    private SingerListMapper singerListMapper;
    @GetMapping("select")
    public Result singer(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        resp.setContentType("application/json;charset=utf-8");
        List<SingerList> list =singerListMapper.findAll();
//        System.out.println(list);
            return new Result("200","显示歌单",list);
    }
    @GetMapping("hynanselect/{lia}")
    public Result hynanSinger(@PathVariable("lia")String lia) throws IOException{

        List<SingerList> list=singerListMapper.findFingerType(lia);
//        System.out.println(list);
        return  new Result("200","查询成功",list);
    }
    @GetMapping("hynvselect/{lia}")
    public Result hynvSinger(@PathVariable("lia")String lia) throws IOException{

        List<SingerList> list=singerListMapper.findFingerType(lia);
        return  new Result("200","查询成功",list);
    }
    @GetMapping("introduction/{id}")
    public Result jjie(@PathVariable("id")String id) throws IOException{//根据id查到歌手的信息
        SingerList singer =singerListMapper.getById(Integer.valueOf(id));
        return new Result("200","查询成功",singer);
    }
    @GetMapping("introducti/{singerName}")
    public Result jje(@PathVariable("singerName")String singerName)
    {
        SingerList singerList =singerListMapper.getByname(singerName);
        return new Result("200","查询成功",singerList);
    }
}
